package com.ccjq.jq173.shosestore.product.service.impl;
import com.ccjq.jq173.shosestore.product.dao.impl.productDaoImpl;
import com.ccjq.jq173.shosestore.product.dao.productDao;
import com.ccjq.jq173.shosestore.product.po.Category;
import com.ccjq.jq173.shosestore.product.po.Product;
import com.ccjq.jq173.shosestore.product.po.Slider;
import com.ccjq.jq173.shosestore.product.service.productService;

import java.sql.Connection;
import java.util.List;

public class productServiceImpl implements productService {

    @Override//查询所有品牌
    public List<Category> getPinPai() {
        productDao p=new productDaoImpl();
        return p.getPinPai();
    }

    @Override//查询所有鞋的信息
    public List<Product> getAllShoes() {
        productDao p=new productDaoImpl();
        return p.getAllShoes();
    }

    @Override//查询指定品牌下的所有信息
    public List<Product> getAllShoes(String productId) {
        productDao p=new productDaoImpl();
        return p.getAllShoes(productId);
    }

    @Override//查询详细信息
    public Product getOneShoes(String productId) {
        productDao p=new productDaoImpl();
        Product product=p.getOneShoes(productId);
        product.setQuantity(Integer.parseInt(p.getStock(productId)));
        return product;
    }

    @Override//查询新品
    public List<Product> getNewShoes() {
        productDao p=new productDaoImpl();
        return p.getNewShoes();
    }

    @Override//查询热卖的三双鞋
    public List<Product> getHotShoes() {
        productDao p=new productDaoImpl();
        return p.getHotShoes();
    }

    @Override//查询滚动条
    public List<Slider> getGunDongShoes() {
        productDao p=new productDaoImpl();
        return p.getGunDongShoes();
    }

    @Override//根据品牌名查询ID
    public String getId(String name) {
        productDao p=new productDaoImpl();
        return p.getId(name);
    }

    @Override//根据品牌ID查询某品牌鞋的信息
    public List<Product> getShoes(String categoryId) {
        productDao p=new productDaoImpl();
        return p.getShoes(categoryId);
    }

    @Override//根据ID查询描述性特征
    public String get(String productId) {
        productDao p=new productDaoImpl();
        return p.get(productId);
    }

    @Override//根据ID查询描述性特征
    public Product getProduct(String productId) {
        productDao p=new productDaoImpl();
        return p.getProduct(productId);
    }

    @Override//根据商品ID更改库存
    public boolean updateStock(int quantity, String productId, Connection con) {
        boolean b = false;
        productDao p=new productDaoImpl();
        b=p.updateStock(quantity,productId,con);
        return b;
    }

    @Override
    public String getPinPai(String categoryId) {
        return new productDaoImpl().getPinPai(categoryId);
    }

    @Override
    public int getCount() {
        return new productDaoImpl().getCount();
    }

    @Override
    public int getCount(String categoryId) {
        return new productDaoImpl().getCount(categoryId);
    }

    @Override
    public List<Product> getAllShoes(int startRow, int pageSize, String categoryId) {
        return new productDaoImpl().getAllShoes(startRow,pageSize,categoryId);
    }

    @Override
    public List<Product> getAllShoes(int startRow, int pageSize) {
        productDao p=new productDaoImpl();
        return p.getAllShoes(startRow,pageSize);
    }

    @Override
    public String getStock(String productId) {
        return new productDaoImpl().getStock(productId);
    }

}